/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */
package com.excesys.exsecs.om.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.nacos.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.excesys.exsecs.admin.api.entity.SysUser;
import com.excesys.exsecs.admin.api.feign.RemoteUserService;
import com.excesys.exsecs.common.core.util.R;
import com.excesys.exsecs.common.security.service.ExsecsUser;
import com.excesys.exsecs.common.security.util.SecurityUtils;
import com.excesys.exsecs.om.constans.OmCommonConstants;
import com.excesys.exsecs.om.dto.EventDto;
import com.excesys.exsecs.om.entity.*;
import com.excesys.exsecs.om.mapper.*;
import com.excesys.exsecs.om.service.OmWEventService;
import com.excesys.exsecs.om.utils.DateUtils;
import com.excesys.exsecs.om.utils.OrderNoUtils;
import com.excesys.exsecs.om.vo.EventVo;
import com.excesys.exsecs.om.vo.HistoryVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
import java.util.Optional;

;

/**
 * 事件表
 *
 * @author weiyj
 * @date 2023-02-24 13:52:55
 */
@Service
@RequiredArgsConstructor
public class OmWEventServiceImpl extends ServiceImpl<OmWEventMapper, OmWEvent> implements OmWEventService {

	private final SequenceMapper sequenceMapper;

	private final OrderNoUtils orderNoUtils;

	private final OmWOrderMapper omWOrderMapper;

	private final OmWOrderHistoryMapper omWOrderHistoryMapper;

	private final RemoteUserService userService;

	private final OmWEventFileMapper omWEventFileMapper;

	private final OmWOrderFileMapper omWOrderFileMapper;

	/**
	 * 分页查询事件信息
	 * @param page 分页对象
	 * @param omWEvent 参数列表
	 * @return
	 */
	@Override
	public IPage<EventVo> getEventWithRelPage(Page page, OmWEvent omWEvent, String flag) {
		long startTime = System.currentTimeMillis();
		IPage<EventVo> iPage = new Page<>();
		if("1".equals(flag)){
			iPage = baseMapper.getEventWithRelPageToday(page, omWEvent);
		}else{
	      iPage = baseMapper.getEventWithRelPage(page, omWEvent);
		}
		long endTime = System.currentTimeMillis();
		System.out.println("查询时间耗时：" + (endTime - startTime) / 1000 + "s");
		long startTime1 = System.currentTimeMillis();
		for (EventVo record : iPage.getRecords()) {
			for (HistoryVo historyVo : record.getHistoryList()) {
				if (null != historyVo.getOperateUserId()) {
					long startTime2 = System.currentTimeMillis();
					R<SysUser> userInfo = userService.getUserById(historyVo.getOperateUserId());
					long endTime2 = System.currentTimeMillis();
					//System.out.println("查询操作人时间耗时：" + (endTime2 - startTime2) / 1000 + "s");
					if (null != userInfo.getData()) {
						historyVo.setOperateUserName(userInfo.getData().getName());
					}
				}
			}
		}
		long endTime1 = System.currentTimeMillis();
		//System.out.println("查询操作人填充时间耗时：" + (endTime1 - startTime1) / 1000 + "s");
		return iPage;
	}

	/**
	 * 分页查询事件信息
	 * @param page 分页对象
	 * @param omWEvent 参数列表
	 * @return
	 */
	@Override
	public IPage<EventVo> getRepairEventWithRelPage(Page page, OmWEvent omWEvent) {
		long startTime = System.currentTimeMillis();
		IPage<EventVo> iPage = baseMapper.getRepairEventWithRelPage(page, omWEvent);
		long endTime = System.currentTimeMillis();
		System.out.println("查询时间耗时：" + (endTime - startTime) / 1000 + "s");
		long startTime1 = System.currentTimeMillis();
		for (EventVo record : iPage.getRecords()) {
			for (HistoryVo historyVo : record.getHistoryList()) {
				if (null != historyVo.getOperateUserId()) {
					long startTime2 = System.currentTimeMillis();
					R<SysUser> userInfo = userService.getUserById(historyVo.getOperateUserId());
					long endTime2 = System.currentTimeMillis();
					System.out.println("查询操作人时间耗时：" + (endTime2 - startTime2) / 1000 + "s");
					if (null != userInfo.getData()) {
						historyVo.setOperateUserName(userInfo.getData().getName());
					}
				}
			}
		}
		long endTime1 = System.currentTimeMillis();
		System.out.println("查询操作人填充时间耗时：" + (endTime1 - startTime1) / 1000 + "s");
		return iPage;
	}

	@Override
	public IPage<EventVo> getMaintenanceEventWithRelPage(Page page, OmWEvent omWEvent) {
		long startTime = System.currentTimeMillis();
		IPage<EventVo> iPage = baseMapper.getMaintenanceEventWithRelPage(page, omWEvent);
		long endTime = System.currentTimeMillis();
		System.out.println("查询时间耗时：" + (endTime - startTime) / 1000 + "s");
		long startTime1 = System.currentTimeMillis();
		for (EventVo record : iPage.getRecords()) {
			for (HistoryVo historyVo : record.getHistoryList()) {
				if (null != historyVo.getOperateUserId()) {
					long startTime2 = System.currentTimeMillis();
					R<SysUser> userInfo = userService.getUserById(historyVo.getOperateUserId());
					long endTime2 = System.currentTimeMillis();
					System.out.println("查询操作人时间耗时：" + (endTime2 - startTime2) / 1000 + "s");
					if (null != userInfo.getData()) {
						historyVo.setOperateUserName(userInfo.getData().getName());
					}
				}
			}
		}
		long endTime1 = System.currentTimeMillis();
		System.out.println("查询操作人填充时间耗时：" + (endTime1 - startTime1) / 1000 + "s");
		return iPage;
	}

	@Override
	public IPage<EventVo> getPage(Page page, OmWEvent omWEvent) {
		long startTime = System.currentTimeMillis();
		IPage<EventVo> iPage = baseMapper.getPage(page, omWEvent);
		long endTime = System.currentTimeMillis();
		System.out.println("查询时间耗时：" + (endTime - startTime) / 1000 + "s");
		long startTime1 = System.currentTimeMillis();
		for (EventVo record : iPage.getRecords()) {
			for (HistoryVo historyVo : record.getHistoryList()) {
				if (null != historyVo.getOperateUserId()) {
					long startTime2 = System.currentTimeMillis();
					R<SysUser> userInfo = userService.getUserById(historyVo.getOperateUserId());
					long endTime2 = System.currentTimeMillis();
					System.out.println("查询操作人时间耗时：" + (endTime2 - startTime2) / 1000 + "s");
					if (null != userInfo.getData()) {
						historyVo.setOperateUserName(userInfo.getData().getName());
					}
				}
			}
		}
		long endTime1 = System.currentTimeMillis();
		System.out.println("查询操作人填充时间耗时：" + (endTime1 - startTime1) / 1000 + "s");
		return iPage;
	}

	@Override
	public IPage<EventVo> getMaintenancePage(Page page, OmWEvent omWEvent) {
		long startTime = System.currentTimeMillis();
		IPage<EventVo> iPage = baseMapper.getMaintenancePage(page, omWEvent);
		long endTime = System.currentTimeMillis();
		System.out.println("查询时间耗时：" + (endTime - startTime) / 1000 + "s");
		long startTime1 = System.currentTimeMillis();
		for (EventVo record : iPage.getRecords()) {
			for (HistoryVo historyVo : record.getHistoryList()) {
				if (null != historyVo.getOperateUserId()) {
					long startTime2 = System.currentTimeMillis();
					R<SysUser> userInfo = userService.getUserById(historyVo.getOperateUserId());
					long endTime2 = System.currentTimeMillis();
					System.out.println("查询操作人时间耗时：" + (endTime2 - startTime2) / 1000 + "s");
					if (null != userInfo.getData()) {
						historyVo.setOperateUserName(userInfo.getData().getName());
					}
				}
			}
		}
		long endTime1 = System.currentTimeMillis();
		System.out.println("查询操作人填充时间耗时：" + (endTime1 - startTime1) / 1000 + "s");
		return iPage;
	}

	@Override
	public String getEventNo() {
		return this.baseMapper.getEventNo();
	}

	@Override
	public String getCurrentEventNameSeq(String typeName) {
		// 生成事件名称
		int order_name_seq = sequenceMapper.getSeqNextVal("event_name_seq");
		String orderNameSeq = orderNoUtils.getOrderName(typeName, order_name_seq);
		return orderNameSeq;
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public Boolean saveEvent(EventDto omWEvent) {

		int eventSeq = sequenceMapper.getSeqNextVal("eventseq");
		omWEvent.setEventNo(orderNoUtils.getOrderNumber("Event", eventSeq));

		OmWOrderHistory omWOrderHistory = new OmWOrderHistory();
		omWOrderHistory.setOperation("创建事件");
		ExsecsUser ExsecsUser = SecurityUtils.getUser();
		omWOrderHistory.setOperateUserId(ExsecsUser.getId());
		omWOrderHistory.setOperateDeptId(ExsecsUser.getDeptId());
		omWOrderHistory.setEventNo(omWEvent.getEventNo());
		omWOrderHistoryMapper.insert(omWOrderHistory);
		omWEvent.setEventStatus(OmCommonConstants.EVENT_STATUS_NO_USER);
		omWEvent.setEventUserId(ExsecsUser.getId());
		omWEvent.setEventUserDeptId(ExsecsUser.getDeptId());
		// 事件转工单
		String handleType = omWEvent.getHandleType();
		if (handleType.equals("1")) {
			// 生成工单entity，设置相应值，并保存
			OmWOrder omWOrder = new OmWOrder();
			omWOrder.setEventNo(omWEvent.getEventNo());

			int orderSeq = sequenceMapper.getSeqNextVal("orderseq");
			omWOrder.setOrderNo(orderNoUtils.getOrderNumber("Order", orderSeq));
			// 同步报告人
			omWOrder.setOrderUserId(omWEvent.getEventUserId());
			omWOrder.setOrderUserName(omWEvent.getEventUserName());
			omWOrder.setOrderUserDeptId(omWEvent.getEventUserDeptId());
			omWOrder.setOrderUserPhone(omWEvent.getEventUserPhone());
			// 同步处理人
			omWOrder.setHandleUserId(omWEvent.getHandleUserId());
			omWOrder.setHandleUserDeptId(omWEvent.getHandleUserDeptId());
			omWOrder.setHandleUserName(omWEvent.getHandleUserName());
			omWOrder.setHandleUserPhone(omWEvent.getHandleUserPhone());

			omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_0);
			omWOrder.setOrderFrom(omWEvent.getEventFromType());
			omWOrder.setOrderType(omWEvent.getEventType());
			omWOrder.setApplyTime(
					LocalDateTime.parse(DateUtil.now(), DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			omWOrder.setOrderName(omWEvent.getEventName());
			omWOrder.setPriorityLevel(omWEvent.getEventLevel());

			omWOrder.setEquipArea(omWEvent.getEventArea());
			omWOrder.setEquipNo(omWEvent.getEquipNo());
			omWOrder.setEquipName(omWEvent.getEquipName());

			omWOrder.setApplyContent(omWEvent.getEventDesc());

			if (null != omWEvent.getHandleUserId()) {
				omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_1);// 创建工单时选择了处理人
																			// 就是待处理状态
			}
			else {
				omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_0);// 创建工单时没有选择了处理人
																			// 就是待指派状态
			}

			// 保存工单附件信息

			Optional.ofNullable(omWEvent.getFileList()).ifPresent(fileLists -> {
				fileLists.stream().map(omWEventFile -> {
					OmWOrderFile owof = new OmWOrderFile();
					owof.setOrderNo(omWOrder.getOrderNo());
					owof.setFileId(omWEventFile.getFileId());
					owof.setUrl(omWEventFile.getUrl());
					owof.setRemark(omWEventFile.getRemark());
					owof.setOriginal(omWEventFile.getOriginal());
					return owof;
				}).forEach(omWOrderFileMapper::insert);
			});

			omWOrderMapper.insert(omWOrder);

			// omWEvent.setEventStatus(eventStatus);
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
		}
		// 保存事件附件信息

		Optional.ofNullable(omWEvent.getFileList()).ifPresent(fileLists -> {
			fileLists.stream().map(omWEventFile -> {
				omWEventFile.setEventNo(omWEvent.getEventNo());
				return omWEventFile;
			}).forEach(omWEventFileMapper::insert);
		});
		return SqlHelper.retBool(this.baseMapper.insert(omWEvent));
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public Boolean saveRepairEvent(EventDto omWEvent) {

		int eventSeq = sequenceMapper.getSeqNextVal("eventseq");
		omWEvent.setEventNo(orderNoUtils.getOrderNumber("Event", eventSeq));

		OmWOrderHistory omWOrderHistory = new OmWOrderHistory();
		omWOrderHistory.setOperation("创建事件");
		ExsecsUser ExsecsUser = SecurityUtils.getUser();
		omWOrderHistory.setOperateUserId(ExsecsUser.getId());
		omWOrderHistory.setOperateDeptId(ExsecsUser.getDeptId());
		omWOrderHistory.setEventNo(omWEvent.getEventNo());
		omWOrderHistoryMapper.insert(omWOrderHistory);
		omWEvent.setEventStatus(OmCommonConstants.EVENT_STATUS_NO_USER);
		omWEvent.setEventUserId(ExsecsUser.getId());
		omWEvent.setEventUserDeptId(ExsecsUser.getDeptId());
		omWEvent.setRepairType("1");
		omWEvent.setEventType("7");
		omWEvent.setSourceOfEvent(omWEvent.getSourceOfEvent());
		// 事件转工单
		String handleType = omWEvent.getHandleType();
		if (handleType.equals("1")) {
			// 生成工单entity，设置相应值，并保存
			OmWOrder omWOrder = new OmWOrder();
			omWOrder.setEventNo(omWEvent.getEventNo());

			int orderSeq = sequenceMapper.getSeqNextVal("orderseq");
			omWOrder.setOrderNo(orderNoUtils.getOrderNumber("Order", orderSeq));
			// 同步报告人
			omWOrder.setOrderUserId(omWEvent.getEventUserId());
			omWOrder.setOrderUserName(omWEvent.getEventUserName());
			omWOrder.setOrderUserDeptId(omWEvent.getEventUserDeptId());
			omWOrder.setOrderUserPhone(omWEvent.getEventUserPhone());
			// 同步处理人
			omWOrder.setHandleUserId(omWEvent.getHandleUserId());
			omWOrder.setHandleUserDeptId(omWEvent.getHandleUserDeptId());
			omWOrder.setHandleUserName(omWEvent.getHandleUserName());
			omWOrder.setHandleUserPhone(omWEvent.getHandleUserPhone());

			omWOrder.setRepairType("1");
			omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_0);
			omWOrder.setOrderFrom(omWEvent.getEventFromType());
			omWOrder.setOrderType(omWEvent.getEventType());
			omWOrder.setApplyTime(
					LocalDateTime.parse(DateUtil.now(), DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			omWOrder.setOrderName(omWEvent.getEventName());
			omWOrder.setPriorityLevel(omWEvent.getEventLevel());

			omWOrder.setEquipArea(omWEvent.getEventArea());
			omWOrder.setEquipNo(omWEvent.getEquipNo());
			omWOrder.setEquipName(omWEvent.getEquipName());

			omWOrder.setApplyContent(omWEvent.getEventDesc());

			if (null != omWEvent.getHandleUserId()) {
				omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_1);// 创建工单时选择了处理人
																			// 就是待处理状态
			}
			else {
				omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_0);// 创建工单时没有选择了处理人
																			// 就是待指派状态
			}

			// 保存工单附件信息

			Optional.ofNullable(omWEvent.getFileList()).ifPresent(fileLists -> {
				fileLists.stream().map(omWEventFile -> {
					OmWOrderFile owof = new OmWOrderFile();
					owof.setOrderNo(omWOrder.getOrderNo());
					owof.setFileId(omWEventFile.getFileId());
					owof.setUrl(omWEventFile.getUrl());
					owof.setRemark(omWEventFile.getRemark());
					owof.setOriginal(omWEventFile.getOriginal());
					return owof;
				}).forEach(omWOrderFileMapper::insert);
			});

			omWOrderMapper.insert(omWOrder);

			// omWEvent.setEventStatus(eventStatus);
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
		}
		// 保存事件附件信息

		Optional.ofNullable(omWEvent.getFileList()).ifPresent(fileLists -> {
			fileLists.stream().map(omWEventFile -> {
				omWEventFile.setEventNo(omWEvent.getEventNo());
				return omWEventFile;
			}).forEach(omWEventFileMapper::insert);
		});
		return SqlHelper.retBool(this.baseMapper.insert(omWEvent));
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public Boolean saveMaintenanceEvent(EventDto omWEvent) {

		int eventSeq = sequenceMapper.getSeqNextVal("eventseq");
		omWEvent.setEventNo(orderNoUtils.getOrderNumber("Event", eventSeq));

		OmWOrderHistory omWOrderHistory = new OmWOrderHistory();
		omWOrderHistory.setOperation("创建事件");
		ExsecsUser ExsecsUser = SecurityUtils.getUser();
		omWOrderHistory.setOperateUserId(ExsecsUser.getId());
		omWOrderHistory.setOperateDeptId(ExsecsUser.getDeptId());
		omWOrderHistory.setEventNo(omWEvent.getEventNo());
		omWOrderHistoryMapper.insert(omWOrderHistory);
		omWEvent.setEventStatus(OmCommonConstants.EVENT_STATUS_NO_USER);
		omWEvent.setEventUserId(ExsecsUser.getId());
		omWEvent.setEventUserDeptId(ExsecsUser.getDeptId());
		omWEvent.setRepairType("2");
		omWEvent.setEventType("8");
		omWEvent.setSourceOfEvent(omWEvent.getSourceOfEvent());
		// 事件转工单
		String handleType = omWEvent.getHandleType();
		if (handleType.equals("1")) {
			// 生成工单entity，设置相应值，并保存
			OmWOrder omWOrder = new OmWOrder();
			omWOrder.setEventNo(omWEvent.getEventNo());

			int orderSeq = sequenceMapper.getSeqNextVal("orderseq");
			omWOrder.setOrderNo(orderNoUtils.getOrderNumber("Order", orderSeq));
			// 同步报告人
			omWOrder.setOrderUserId(omWEvent.getEventUserId());
			omWOrder.setOrderUserName(omWEvent.getEventUserName());
			omWOrder.setOrderUserDeptId(omWEvent.getEventUserDeptId());
			omWOrder.setOrderUserPhone(omWEvent.getEventUserPhone());
			// 同步处理人
			omWOrder.setHandleUserId(omWEvent.getHandleUserId());
			omWOrder.setHandleUserDeptId(omWEvent.getHandleUserDeptId());
			omWOrder.setHandleUserName(omWEvent.getHandleUserName());
			omWOrder.setHandleUserPhone(omWEvent.getHandleUserPhone());

			omWOrder.setRepairType("2");
			omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_0);
			omWOrder.setOrderFrom(omWEvent.getEventFromType());
			omWOrder.setOrderType(omWEvent.getEventType());
			omWOrder.setApplyTime(
					LocalDateTime.parse(DateUtil.now(), DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			omWOrder.setOrderName(omWEvent.getEventName());
			omWOrder.setPriorityLevel(omWEvent.getEventLevel());

			omWOrder.setEquipArea(omWEvent.getEventArea());
			omWOrder.setEquipNo(omWEvent.getEquipNo());
			omWOrder.setEquipName(omWEvent.getEquipName());

			omWOrder.setApplyContent(omWEvent.getEventDesc());

			if (null != omWEvent.getHandleUserId()) {
				omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_1);// 创建工单时选择了处理人
																			// 就是待处理状态
			}
			else {
				omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_0);// 创建工单时没有选择了处理人
																			// 就是待指派状态
			}

			// 保存工单附件信息

			Optional.ofNullable(omWEvent.getFileList()).ifPresent(fileLists -> {
				fileLists.stream().map(omWEventFile -> {
					OmWOrderFile owof = new OmWOrderFile();
					owof.setOrderNo(omWOrder.getOrderNo());
					owof.setFileId(omWEventFile.getFileId());
					owof.setUrl(omWEventFile.getUrl());
					owof.setRemark(omWEventFile.getRemark());
					owof.setOriginal(omWEventFile.getOriginal());
					return owof;
				}).forEach(omWOrderFileMapper::insert);
			});

			omWOrderMapper.insert(omWOrder);

			// omWEvent.setEventStatus(eventStatus);
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
		}
		// 保存事件附件信息

		Optional.ofNullable(omWEvent.getFileList()).ifPresent(fileLists -> {
			fileLists.stream().map(omWEventFile -> {
				omWEventFile.setEventNo(omWEvent.getEventNo());
				return omWEventFile;
			}).forEach(omWEventFileMapper::insert);
		});
		return SqlHelper.retBool(this.baseMapper.insert(omWEvent));
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public Boolean updateEvent(EventDto omWEvent) {
		OmWOrderHistory omWOrderHistory = new OmWOrderHistory();
		omWOrderHistory.setOperation("修改事件");
		ExsecsUser ExsecsUser = SecurityUtils.getUser();
		omWOrderHistory.setOperateUserId(ExsecsUser.getId());
		omWOrderHistory.setOperateDeptId(ExsecsUser.getDeptId());
		omWOrderHistory.setEventNo(omWEvent.getEventNo());
		omWOrderHistoryMapper.insert(omWOrderHistory);
		omWEventFileMapper
				.delete(Wrappers.<OmWEventFile>update().lambda().eq(OmWEventFile::getEventNo, omWEvent.getEventNo()));
		Optional.ofNullable(omWEvent.getFileList()).ifPresent(fileLists -> {
			fileLists.stream().map(omWEventFile -> {
				omWEventFile.setEventNo(omWEvent.getEventNo());
				return omWEventFile;
			}).forEach(omWEventFileMapper::insert);
		});
		return SqlHelper.retBool(this.getBaseMapper().updateById(omWEvent));
	}

	@Override
	public R<Boolean> operateOmWEvent(EventDto eventDto) {

		String eventStatus = eventDto.getEventStatus();

		Boolean isok = true;
		String returnMsg = "";
		String operation = "";

		OmWEvent omWEvent = new OmWEvent();
		omWEvent.setEventNo(eventDto.getEventNo());
		omWEvent = this.getOne(new QueryWrapper<>(omWEvent));
		System.out.println("打印数据库查出来得值：" + omWEvent);

		// 补全history信息
		OmWOrderHistory omWOrderHistory = new OmWOrderHistory();
		ExsecsUser ExsecsUser = SecurityUtils.getUser();
		omWOrderHistory.setOperateUserId(ExsecsUser.getId());
		omWOrderHistory.setOperateDeptId(ExsecsUser.getDeptId());
		omWOrderHistory.setEventNo(omWEvent.getEventNo());

		// 处理事件
		if ("0".equals(omWEvent.getEventStatus())) {
			// 未处理的事件才能处理
			if (eventStatus.equals("0")) {
				omWEvent.setEventStatus(OmCommonConstants.EVENT_STATUS_1);
				omWEvent.setHandleUserDeptId(ExsecsUser.getDeptId());
				omWEvent.setHandleUserId(ExsecsUser.getId());
				omWEvent.setHandleUserName(ExsecsUser.getName());
				omWEvent.setHandleUserPhone(ExsecsUser.getPhone());
				this.getBaseMapper().updateById(omWEvent);
				operation = "处理事件";
				returnMsg = "事件处理中";
			}
			else {
				isok = false;
				returnMsg = "事件当前状态不能指派";
			}

		}

		// 指派事件
		if ("6".equals(omWEvent.getEventStatus())) {
			// 管理员和服务台进入未指派、已指派、处理中、挂起状态的事件详情进行指派或重新选择处理企业和处理人
			if ("6".equals(omWEvent.getEventStatus()) || "1".equals(omWEvent.getEventStatus())
					|| "2".equals(omWEvent.getEventStatus()) || "4".equals(omWEvent.getEventStatus())) {
				omWEvent.setEventStatus(OmCommonConstants.EVENT_STATUS_WAIT);
				omWEvent.setHandleUserDeptId(eventDto.getHandleUserDeptId());
				omWEvent.setHandleUserId(eventDto.getHandleUserId());

				R<SysUser> userInfo = userService.getUserById(eventDto.getHandleUserId());
				omWEvent.setHandleUserName(userInfo.getData().getUsername());
				omWEvent.setHandleUserPhone(userInfo.getData().getPhone());

				this.getBaseMapper().updateById(omWEvent);
				returnMsg = "事件已指派";
				operation = "指派事件";
			}
			else {
				isok = false;
				returnMsg = "事件当前状态不能指派";
			}

		}

		// 事件处理完成
		if ("2".equals(eventStatus)) {
			omWEvent.setEventStatus(eventStatus);
			omWEvent.setHandleTime(
					LocalDateTime.parse(DateUtil.now(), DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件处理完成";
			returnMsg = "事件已处理";
		}

		// 事件转工单
		if ("3".equals(eventStatus)) {
			// 生成工单entity，设置相应值，并保存
			OmWOrder omWOrder = new OmWOrder();
			omWOrder.setEventNo(omWEvent.getEventNo());

			int orderSeq = sequenceMapper.getSeqNextVal("orderseq");
			omWOrder.setOrderNo(orderNoUtils.getOrderNumber("Order", orderSeq));
			// 同步报告人
			omWOrder.setOrderUserId(omWEvent.getEventUserId());
			if (StringUtils.isNotEmpty(omWEvent.getEventUserName()))
				omWOrder.setOrderUserName(omWEvent.getEventUserName());
			omWOrder.setOrderUserDeptId(omWEvent.getEventUserDeptId());
			if (StringUtils.isNotEmpty(omWEvent.getEventUserPhone()))
				omWOrder.setOrderUserPhone(omWEvent.getEventUserPhone());
			// 同步处理人
			if (omWEvent.getHandleUserId() == null || omWEvent.getHandleUserId().longValue() == 0)
				omWOrder.setHandleUserId(omWEvent.getHandleUserId());
			if (omWEvent.getHandleUserDeptId() == null || omWEvent.getHandleUserDeptId().longValue() == 0)
				omWOrder.setHandleUserDeptId(omWEvent.getHandleUserDeptId());
			if (StringUtils.isNotEmpty(omWEvent.getHandleUserName()))
				omWOrder.setHandleUserName(omWEvent.getHandleUserName());
			if (StringUtils.isNotEmpty(omWEvent.getHandleUserPhone()))
				omWOrder.setHandleUserPhone(omWEvent.getHandleUserPhone());

			omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_0);
			if (StringUtils.isNotEmpty(omWEvent.getEventFromType()))
				omWOrder.setOrderFrom(omWEvent.getEventFromType());
			if (StringUtils.isNotEmpty(omWEvent.getEventType()))
				omWOrder.setOrderType(omWEvent.getEventType());
			omWOrder.setApplyTime(
					LocalDateTime.parse(DateUtil.now(), DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			omWOrder.setOrderName(omWEvent.getEventName());
			if (StringUtils.isNotEmpty(omWEvent.getEventLevel()))
				omWOrder.setPriorityLevel(omWEvent.getEventLevel());

			omWOrder.setEquipArea(omWEvent.getEventArea());
			if (StringUtils.isNotEmpty(omWEvent.getEquipNo()))
				omWOrder.setEquipNo(omWEvent.getEquipNo());
			if (StringUtils.isNotEmpty(omWEvent.getEquipName()))
				omWOrder.setEquipName(omWEvent.getEquipName());

			if (StringUtils.isNotEmpty(omWEvent.getEventDesc()))
				omWOrder.setApplyContent(omWEvent.getEventDesc());

			if (StrUtil.isNotEmpty(omWEvent.getHandleUserId().toString())) {
				omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_1);// 创建工单时选择了处理人
																			// 就是待处理状态
			}
			else {
				omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_0);// 创建工单时没有选择了处理人
																			// 就是待指派状态
			}
			omWOrderMapper.insert(omWOrder);

			omWEvent.setEventStatus(eventStatus);
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件转工单";
			returnMsg = "事件转工单";
		}

		// 事件关闭
		if ("4".equals(eventStatus)) {
			omWEvent.setEventStatus(eventStatus);
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件关闭";
			returnMsg = "事件关闭";
		}

		// 事件评价
		if ("5".equals(eventStatus)) {
			omWEvent.setEventStatus(eventStatus);
			omWEvent.setReviewDesc(eventDto.getReviewDesc());
			omWEvent.setReviewLevel(eventDto.getReviewLevel());
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件评价";
			returnMsg = "事件评价";
		}

		omWOrderHistory.setOperation(operation);
		omWOrderHistoryMapper.insert(omWOrderHistory);
		return R.ok(isok, returnMsg);
	}

	@Override
	public R<Boolean> operateOmRepairEvent(EventDto eventDto) {

		String eventStatus = eventDto.getEventStatus();

		Boolean isok = true;
		String returnMsg = "";
		String operation = "";

		OmWEvent omWEvent = new OmWEvent();
		omWEvent.setEventNo(eventDto.getEventNo());
		omWEvent = this.getOne(new QueryWrapper<>(omWEvent));
		System.out.println("打印数据库查出来得值：" + omWEvent);

		// 补全history信息
		OmWOrderHistory omWOrderHistory = new OmWOrderHistory();
		ExsecsUser ExsecsUser = SecurityUtils.getUser();
		omWOrderHistory.setOperateUserId(ExsecsUser.getId());
		omWOrderHistory.setOperateDeptId(ExsecsUser.getDeptId());
		omWOrderHistory.setEventNo(omWEvent.getEventNo());

		// 处理事件
		if ("0".equals(omWEvent.getEventStatus())) {
			// 未处理的事件才能处理
			if (eventStatus.equals("0")) {
				omWEvent.setEventStatus(OmCommonConstants.EVENT_STATUS_1);
				omWEvent.setHandleUserDeptId(ExsecsUser.getDeptId());
				omWEvent.setHandleUserId(ExsecsUser.getId());
				omWEvent.setHandleUserName(ExsecsUser.getName());
				omWEvent.setHandleUserPhone(ExsecsUser.getPhone());
				this.getBaseMapper().updateById(omWEvent);
				operation = "处理事件";
				returnMsg = "事件处理中";
			}
			else {
				isok = false;
				returnMsg = "事件当前状态不能指派";
			}

		}

		// 指派事件
		if ("6".equals(eventStatus)) {
			// 管理员和服务台进入未指派、已指派、处理中、挂起状态的事件详情进行指派或重新选择处理企业和处理人
			if ("6".equals(omWEvent.getEventStatus()) || "1".equals(omWEvent.getEventStatus())
					|| "2".equals(omWEvent.getEventStatus()) || "4".equals(omWEvent.getEventStatus())) {
				omWEvent.setEventStatus(OmCommonConstants.EVENT_STATUS_WAIT);
				omWEvent.setHandleUserDeptId(eventDto.getHandleUserDeptId());
				omWEvent.setHandleUserId(eventDto.getHandleUserId());

				R<SysUser> userInfo = userService.getUserById(eventDto.getHandleUserId());
				omWEvent.setHandleUserName(userInfo.getData().getUsername());
				omWEvent.setHandleUserPhone(userInfo.getData().getPhone());

				this.getBaseMapper().updateById(omWEvent);
				returnMsg = "事件已指派";
				operation = "指派事件";
			}
			else {
				isok = false;
				returnMsg = "事件当前状态不能指派";
			}

		}

		// 事件处理完成
		if ("2".equals(eventStatus)) {
			omWEvent.setEventStatus(eventStatus);
			omWEvent.setHandleTime(
					LocalDateTime.parse(DateUtil.now(), DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件处理完成";
			returnMsg = "事件已处理";
		}

		// 事件转工单
		if ("3".equals(eventStatus)) {
			// 生成工单entity，设置相应值，并保存
			OmWOrder omWOrder = new OmWOrder();
			omWOrder.setEventNo(omWEvent.getEventNo());

			int orderSeq = sequenceMapper.getSeqNextVal("orderseq");
			omWOrder.setOrderNo(orderNoUtils.getOrderNumber("Order", orderSeq));
			// 同步报告人
			omWOrder.setOrderUserId(omWEvent.getEventUserId());
			if (StringUtils.isNotEmpty(omWEvent.getEventUserName()))
				omWOrder.setOrderUserName(omWEvent.getEventUserName());
			omWOrder.setOrderUserDeptId(omWEvent.getEventUserDeptId());
			if (StringUtils.isNotEmpty(omWEvent.getEventUserPhone()))
				omWOrder.setOrderUserPhone(omWEvent.getEventUserPhone());
			// 同步处理人
			if (omWEvent.getHandleUserId() == null || omWEvent.getHandleUserId().longValue() == 0)
				omWOrder.setHandleUserId(omWEvent.getHandleUserId());
			if (omWEvent.getHandleUserDeptId() == null || omWEvent.getHandleUserDeptId().longValue() == 0)
				omWOrder.setHandleUserDeptId(omWEvent.getHandleUserDeptId());
			if (StringUtils.isNotEmpty(omWEvent.getHandleUserName()))
				omWOrder.setHandleUserName(omWEvent.getHandleUserName());
			if (StringUtils.isNotEmpty(omWEvent.getHandleUserPhone()))
				omWOrder.setHandleUserPhone(omWEvent.getHandleUserPhone());
			omWOrder.setRepairType("1");
			omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_0);
			if (StringUtils.isNotEmpty(omWEvent.getEventFromType()))
				omWOrder.setOrderFrom(omWEvent.getEventFromType());
			if (StringUtils.isNotEmpty(omWEvent.getEventType()))
				omWOrder.setOrderType(omWEvent.getEventType());
			omWOrder.setApplyTime(
					LocalDateTime.parse(DateUtil.now(), DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			omWOrder.setOrderName(omWEvent.getEventName());
			if (StringUtils.isNotEmpty(omWEvent.getEventLevel()))
				omWOrder.setPriorityLevel(omWEvent.getEventLevel());

			omWOrder.setEquipArea(omWEvent.getEventArea());
			if (StringUtils.isNotEmpty(omWEvent.getEquipNo()))
				omWOrder.setEquipNo(omWEvent.getEquipNo());
			if (StringUtils.isNotEmpty(omWEvent.getEquipName()))
				omWOrder.setEquipName(omWEvent.getEquipName());

			if (StringUtils.isNotEmpty(omWEvent.getEventDesc()))
				omWOrder.setApplyContent(omWEvent.getEventDesc());

			if (omWEvent.getHandleUserId() == null) {
				omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_0);// 创建工单时没有选择了处理人
																			// 就是待指派状态
			}
			else {
				omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_1);// 创建工单时选择了处理人
																			// 就是待处理状态

			}
			omWOrderMapper.insert(omWOrder);

			omWEvent.setEventStatus(eventStatus);
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件转工单";
			returnMsg = "事件转工单";
		}

		// 事件关闭
		if ("4".equals(eventStatus)) {
			omWEvent.setCause(omWEvent.getCause());
			omWEvent.setEventStatus(eventStatus);
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件关闭";
			returnMsg = "事件关闭";
		}

		// 事件评价
		if ("5".equals(eventStatus)) {
			omWEvent.setEventStatus(eventStatus);
			omWEvent.setReviewDesc(eventDto.getReviewDesc());
			omWEvent.setReviewLevel(eventDto.getReviewLevel());
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件评价";
			returnMsg = "事件评价";
		}

		// 事件取消
		if ("7".equals(eventStatus)) {
			omWEvent.setCause(omWEvent.getCause());
			omWEvent.setEventStatus(eventStatus);
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件取消";
			returnMsg = "事件取消";
		}

		// 事件重新打开
		if ("8".equals(eventStatus)) {
			omWEvent.setCause(omWEvent.getCause());
			omWEvent.setEventStatus(eventStatus);
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件重新打开";
			returnMsg = "事件重新打开";
		}
		omWOrderHistory.setOperation(operation);
		omWOrderHistoryMapper.insert(omWOrderHistory);
		return R.ok(isok, returnMsg);
	}

	@Override
	public R<Boolean> operateOmMaintenanceEvent(EventDto eventDto) {

		String eventStatus = eventDto.getEventStatus();

		Boolean isok = true;
		String returnMsg = "";
		String operation = "";

		OmWEvent omWEvent = new OmWEvent();
		omWEvent.setEventNo(eventDto.getEventNo());
		omWEvent = this.getOne(new QueryWrapper<>(omWEvent));
		System.out.println("打印数据库查出来得值：" + omWEvent);

		// 补全history信息
		OmWOrderHistory omWOrderHistory = new OmWOrderHistory();
		ExsecsUser ExsecsUser = SecurityUtils.getUser();
		omWOrderHistory.setOperateUserId(ExsecsUser.getId());
		omWOrderHistory.setOperateDeptId(ExsecsUser.getDeptId());
		omWOrderHistory.setEventNo(omWEvent.getEventNo());

		// 处理事件
		if ("0".equals(omWEvent.getEventStatus())) {
			// 未处理的事件才能处理
			if (eventStatus.equals("0")) {
				omWEvent.setEventStatus(OmCommonConstants.EVENT_STATUS_1);
				omWEvent.setHandleUserDeptId(ExsecsUser.getDeptId());
				omWEvent.setHandleUserId(ExsecsUser.getId());
				omWEvent.setHandleUserName(ExsecsUser.getName());
				omWEvent.setHandleUserPhone(ExsecsUser.getPhone());
				this.getBaseMapper().updateById(omWEvent);
				operation = "处理事件";
				returnMsg = "事件处理中";
			}
			else {
				isok = false;
				returnMsg = "事件当前状态不能指派";
			}

		}

		// 指派事件
		if ("6".equals(eventStatus)) {
			// 管理员和服务台进入未指派、已指派、处理中、挂起状态的事件详情进行指派或重新选择处理企业和处理人
			if ("6".equals(omWEvent.getEventStatus()) || "1".equals(omWEvent.getEventStatus())
					|| "2".equals(omWEvent.getEventStatus()) || "4".equals(omWEvent.getEventStatus())) {
				omWEvent.setEventStatus(OmCommonConstants.EVENT_STATUS_WAIT);
				omWEvent.setHandleUserDeptId(eventDto.getHandleUserDeptId());
				omWEvent.setHandleUserId(eventDto.getHandleUserId());

				R<SysUser> userInfo = userService.getUserById(eventDto.getHandleUserId());
				omWEvent.setHandleUserName(userInfo.getData().getUsername());
				omWEvent.setHandleUserPhone(userInfo.getData().getPhone());

				this.getBaseMapper().updateById(omWEvent);
				returnMsg = "事件已指派";
				operation = "指派事件";
			}
			else {
				isok = false;
				returnMsg = "事件当前状态不能指派";
			}

		}

		// 事件处理完成
		if ("2".equals(eventStatus)) {
			omWEvent.setEventStatus(eventStatus);
			omWEvent.setHandleTime(
					LocalDateTime.parse(DateUtil.now(), DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件处理完成";
			returnMsg = "事件已处理";
		}

		// 事件转工单
		if ("3".equals(eventStatus)) {
			// 生成工单entity，设置相应值，并保存
			OmWOrder omWOrder = new OmWOrder();
			omWOrder.setEventNo(omWEvent.getEventNo());

			int orderSeq = sequenceMapper.getSeqNextVal("orderseq");
			omWOrder.setOrderNo(orderNoUtils.getOrderNumber("Order", orderSeq));
			// 同步报告人
			omWOrder.setOrderUserId(omWEvent.getEventUserId());
			if (StringUtils.isNotEmpty(omWEvent.getEventUserName()))
				omWOrder.setOrderUserName(omWEvent.getEventUserName());
			omWOrder.setOrderUserDeptId(omWEvent.getEventUserDeptId());
			if (StringUtils.isNotEmpty(omWEvent.getEventUserPhone()))
				omWOrder.setOrderUserPhone(omWEvent.getEventUserPhone());
			// 同步处理人
			if (omWEvent.getHandleUserId() == null || omWEvent.getHandleUserId().longValue() == 0)
				omWOrder.setHandleUserId(omWEvent.getHandleUserId());
			if (omWEvent.getHandleUserDeptId() == null || omWEvent.getHandleUserDeptId().longValue() == 0)
				omWOrder.setHandleUserDeptId(omWEvent.getHandleUserDeptId());
			if (StringUtils.isNotEmpty(omWEvent.getHandleUserName()))
				omWOrder.setHandleUserName(omWEvent.getHandleUserName());
			if (StringUtils.isNotEmpty(omWEvent.getHandleUserPhone()))
				omWOrder.setHandleUserPhone(omWEvent.getHandleUserPhone());
			omWOrder.setRepairType("2");
			omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_0);
			if (StringUtils.isNotEmpty(omWEvent.getEventFromType()))
				omWOrder.setOrderFrom(omWEvent.getEventFromType());
			if (StringUtils.isNotEmpty(omWEvent.getEventType()))
				omWOrder.setOrderType(omWEvent.getEventType());
			omWOrder.setApplyTime(
					LocalDateTime.parse(DateUtil.now(), DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			omWOrder.setOrderName(omWEvent.getEventName());
			if (StringUtils.isNotEmpty(omWEvent.getEventLevel()))
				omWOrder.setPriorityLevel(omWEvent.getEventLevel());

			omWOrder.setEquipArea(omWEvent.getEventArea());
			if (StringUtils.isNotEmpty(omWEvent.getEquipNo()))
				omWOrder.setEquipNo(omWEvent.getEquipNo());
			if (StringUtils.isNotEmpty(omWEvent.getEquipName()))
				omWOrder.setEquipName(omWEvent.getEquipName());

			if (StringUtils.isNotEmpty(omWEvent.getEventDesc()))
				omWOrder.setApplyContent(omWEvent.getEventDesc());

			if (omWEvent.getHandleUserId() == null) {
				omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_0);// 创建工单时没有选择了处理人
																			// 就是待指派状态
			}
			else {
				omWOrder.setOrderStatus(OmCommonConstants.ORDER_STATUS_1);// 创建工单时选择了处理人
																			// 就是待处理状态

			}
			omWOrderMapper.insert(omWOrder);

			omWEvent.setEventStatus(eventStatus);
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件转工单";
			returnMsg = "事件转工单";
		}

		// 事件关闭
		if ("4".equals(eventStatus)) {
			omWEvent.setCause(omWEvent.getCause());
			omWEvent.setEventStatus(eventStatus);
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件关闭";
			returnMsg = "事件关闭";
		}

		// 事件评价
		if ("5".equals(eventStatus)) {
			omWEvent.setEventStatus(eventStatus);
			omWEvent.setReviewDesc(eventDto.getReviewDesc());
			omWEvent.setReviewLevel(eventDto.getReviewLevel());
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件评价";
			returnMsg = "事件评价";
		}

		// 事件取消
		if ("7".equals(eventStatus)) {
			omWEvent.setCause(omWEvent.getCause());
			omWEvent.setEventStatus(eventStatus);
			// omWEvent.setHandleTime(LocalDateTime.parse(DateUtil.now(),
			// DateTimeFormatter.ofPattern(DateUtils.DATE_FORMATE_STRING_A)));
			this.getBaseMapper().updateById(omWEvent);
			operation = "事件取消";
			returnMsg = "事件取消";
		}
		omWOrderHistory.setOperation(operation);
		omWOrderHistoryMapper.insert(omWOrderHistory);
		return R.ok(isok, returnMsg);
	}

	@Override
	public Map<String, String> getEventCountMap(Long userId, Long createUserId) {
		return this.getBaseMapper().getEventCountMap(userId, createUserId);
	}

}
